<%@page import="java.util.*"%>
<%@page import="Data.*"%>
<%@page import="java.text.*"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <link rel="icon" href="/images/mystuff.ico" type="image/x-icon">
        <link rel="shortcut icon" href="/images/mystuff.ico" type="image/x-icon">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>MyStuff  |  Buy Stuff</title>
    <style type="text/css">
<!--
body {
	background-color: #FFFFFF;
	background-image: url(Images/background_grad_small.gif);
	background-repeat: repeat-x;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
    </style>
    <link href="mystuff_text.css" rel="stylesheet" type="text/css">
    <link href="mystuff_layout.css" rel="stylesheet" type="text/css">
    <script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
    </script>
    <style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #666666}
-->
    </style>
    </head>
    <body onLoad="MM_preloadImages('Images/cancel_transaction_over.gif','Images/button_checkout_over.png','Images/button_clear_cart_over.png')">
        <div id="main_container">
			<div id="interface_nav_container">
				<div id="small_logo">
					<img src="Images/logo_small.gif">
				</div>
				<div id="interface_top_swap">
					<img src="Images/top_rent_stuff.jpg" width="169" height="111"></div>
			</div><!-- /interface_nav_container -->
			<div id="step_cancel_container">
				<div class="step">
					<img src="Images/step_1.gif">
					<img src="Images/step_1_pick_rent.gif" width="258" height="57">				
				</div>
				<div class="cancel">				
					<a href="#" onMouseOver="MM_swapImage('cancel','','Images/cancel_transaction_over.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="Images/cancel_transaction_off.gif" name="cancel" border="0" id="cancel"></a> </div>
			</div><!-- /step_cancel_container -->
			<div id="buy_boxes">
                     <div id="inventory_frame">				
							<table width="410" border="0" cellspacing="0">
								<thead class="inventory_header">
									<tr class="inventory_header">
										<th width="54"><div align="center">Item#</div></th>
										<th width="184"><div align="center">Description</div></th>
										<th width="61"><div align="center">Price</div></th>
										<th width="43"><div align="center">Qty</div></th>
										<th width="58">&nbsp;</th>
									</tr>
									
								</thead>
								<tbody>
                                                <% 
                                                //Create format for Dollar amounts
                                                NumberFormat form = NumberFormat.getCurrencyInstance();
                                                List<ConceptualProductBO> conceptualProductList = (List)session.getAttribute("conceptualProductList");
                                                
                                                for (int i = 0; i < conceptualProductList.size(); i++) {
                                                ConceptualProductBO conceptualProduct = conceptualProductList.get(i);
                                                out.println("<form name=\"form"+ i + "\" action=\"edu.byu.isys413.actions.AddProductToCart.action\" method=\"POST\">");
                                                if (i%2 == 0){
                                                out.println("<tr>");
                                                out.println("<td class=\"item_num\">");
                                                out.println(conceptualProduct.getId());
                                                out.println("<input type=\"hidden\" name=\"id\" value=\"" + conceptualProduct.getId() + "\">");
                                                out.println("</td>");
                                                out.println("<td class=\"item_description\">");
                                                out.println(conceptualProduct.getDescription());
                                                out.println("</td>");
                                                out.println("<td class=\"item_price\">");
                                                out.println(conceptualProduct.getPrice());
                                                out.println("</td>");
                                                out.println("<td>");
                                                out.println("<input type=\"text\" name=\"quantity\" size=\"1\">");
                                                out.println("</td>");
                                                out.println("<td>");
                                                out.println("<a href=\"javascript:document.form" + i + ".submit()\"><img src=\"Images/button_add.gif\" border=\"0\" alt=\"Add item to cart\" width=\"58\" height=\"23\"></a>");
                                                out.println("</td>");
                                                out.println("</tr>");
                                                out.println("</form>");
                                                }//if
                                                else{
                                                out.println("<tr>");
                                                out.println("<td bgcolor=\"#F7F7F7\" class=\"item_num\">");
                                                out.println(conceptualProduct.getId());
                                                out.println("<input type=\"hidden\" name=\"id\" value=\"" + conceptualProduct.getId() + "\">");
                                                out.println("</td>");
                                                out.println("<td bgcolor=\"#F7F7F7\" class=\"item_description\">");
                                                out.println(conceptualProduct.getDescription());
                                                out.println("</td>");
                                                out.println("<td bgcolor=\"#F7F7F7\" class=\"item_price\">");
                                                out.println(conceptualProduct.getPrice());
                                                out.println("</td>");
                                                out.println("<td bgcolor=\"#F7F7F7\">");
                                                out.println("<input type=\"text\" name=\"quantity\" size=\"1\">");
                                                out.println("</td>");
                                                out.println("<td bgcolor=\"#F7F7F7\">");
                                                out.println("<a href=\"javascript:document.form" + i + ".submit()\"><img src=\"Images/button_add.gif\" border=\"0\" alt=\"Add item to cart\" width=\"58\" height=\"23\"></a>");
                                                out.println("</td>");
                                                out.println("</tr>");
                                                out.println("</form>");
                                                }//else
                                                }//for
                                                
                                                %>
                                                
                              </tbody>
                       </table>
                                   
				</div><!-- /inventory_frame -->
				<div id="shopping_cart_container">				
					<div class="cart_header" align="center"><img src="Images/myCart.gif" alt="My Shopping Cart" width="149" height="22"></div>
					<div class="rent_cart_items" align="center"><br>
					    <span class="how_long style2">I want to rent:</span> <br>
					  						  <span class="style1">{insert selected item here}</span> <br>
						<img src="Images/step_2.gif" width="117" height="54"> &nbsp;&nbsp;<br>
						<span class="how_long">Choose your Rental Length </span><br> 
						<br>
						<select name="cmbDaysToRent" size="1">
						  <option>1</option>
						  <option>2</option>
						  <option>3</option>
						  <option>4</option>
						  <option>5</option>
						  <option>6</option>
						  <option>7</option>
						  <option>8</option>
						  <option>9</option>
						  <option>10</option>
						</select> 
						<span class="how_long">days </span>				  </div>
					<div class="cart_controls" align="center"></div>
					<div class="cart_buttons" align="center">					
						<a href="#"><img src="Images/button_clear_cart_off.gif" name="clear_cart" border="0" id="clear_cart" onMouseOver="MM_swapImage('clear_cart','','Images/button_clear_cart_over.png',1)" onMouseOut="MM_swapImgRestore()"></a>
						<a href="#"><img src="Images/button_checkout_off.gif" name="checkout" border="0" id="checkout" onMouseOver="MM_swapImage('checkout','','Images/button_checkout_over.png',1)" onMouseOut="MM_swapImgRestore()"></a> </div>
				</div><!-- /shopping_cart_container -->
			</div><!-- /buy boxes -->
		</div><!-- /main_container -->

    <h1>Rent Stuff</h1>
         <%=request.getAttribute("message")%><br>
         <%=request.getAttribute("message2")%>
        <form action="edu.byu.isys413.actions.rentStuff.action" method = "POST">
            <h3>Please select a rental item category:</h3><br>
            <input type="radio" name="group1" value="Camera">Camera <br>
            <input type="radio" name="group1" value="Tripod">Tripod <br>
            <input type="radio" name="group1" value="Video">Video Camera <br>
            <input type="radio" name="group1" value="Projector">Projector <br>
            <h3>How many days would you like to rent for?</h3> 
            <input type="text" name="DaysToRent" value=""> <br>
            <input type="submit">
        </form>
     
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
        <!-- Let's welcome the user ${param.name} -->
        Hello ${param.name}!
    </c:if>
    --%>
    
    </body>
</html>
